

# class Solution:
#     def sum(self, nums, target):
#         """
#         :type nums: List[int]
#         :type target: int
#         :rtype: List[int]
#         :return:
#         """
#         n = len(nums)
#         target = 9
#         for i in range(n):
#             for m in range(i+1, n):
#                 if nums[i] + nums[m] == target:
#                     return[i, m]
#         return []

class Solution:

    def Sum(self, nums, target):
        n = len(nums)
        #  使用哈希表记录数值和下标
        hash_table = {}
        for i in range(n):
            #  检查哈希表中是否存在target-nums[i]
            if target - nums[i] in hash_table:
                #  返回前面数值的下标和当前数值的下标
                return [hash_table[target - nums[i]], i]
            #  不断更新哈希表
            hash_table[nums[i]] = i
            print(hash_table)
        return []


if __name__ == '__main__':
    sol = Solution()
    res = sol.Sum(nums=[2, 4, 7, 33, 9], target=35)
    print(res)